package com.jiayen.dialog;

import android.content.Context;

import com.kaopiz.kprogresshud.KProgressHUD;

/**
 * Created by jiayen on 16/9/30.
 *
 * 加载dialog   加载的时候显示
 */
public class LoadingDialog{
    private Context mContext;

    private KProgressHUD loading;
    public LoadingDialog(Context context) {
        this.mContext=context;
    }

    public void show(){
        try {
            if(loading==null)
                loading = KProgressHUD.create(mContext)
                        .setStyle(KProgressHUD.Style.SPIN_INDETERMINATE)
                        .setCancellable(true)
                        .setDimAmount(0.5f);
            if(!loading.isShowing())
                loading.show();
        }catch (Exception e){

        }

    }
    public void cancel(){
        try {
            if(loading!=null&&loading.isShowing())
                loading.dismiss();
        }catch (Exception e){
        }

    }
}
